﻿namespace npantarhei.contrib.tests
{
	using System;
	using System.ComponentModel.Composition.Hosting;
	using Microsoft.VisualStudio.TestTools.UnitTesting;
	using npantarhei.runtime;

	[TestClass]
	public class ExportedOperation_Tests
	{
		[TestMethod]
		public void SimpleFlow_Returns_RevertedText()
		{
			var source = "This is a sample string";
			var result = string.Empty;
			var worker = new StringWorker();

			var frc = new FlowRuntimeConfiguration();
			var container = new CompositionContainer(new AssemblyCatalog(this.GetType().Assembly));
			frc.AddStreamsFrom("npantarhei.contrib.tests.RevertText.flow", this.GetType().Assembly);
			frc.Configure(container);

			var fr = new FlowRuntime();
			fr.Configure(frc);
			fr.Process(".in", source);
			fr.WaitForResult(1000, message => result = message.Data.ToString());

			Assert.AreEqual(worker.RevertText(source), result);
		}
	}
}
